package com.yxcz.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.socket.TextMessage;

import com.yxcz.websocket.SystemWebSocketHandler;

@Controller
@RequestMapping("/websocket")
public class WebSocketController {
	
	@Resource
    private SystemWebSocketHandler systemWebSocketHandler;
	// 测试
	@RequestMapping(value = "/test")
	public ModelAndView test(ModelAndView modelAndView, HttpSession session) {
		modelAndView.setViewName("websocket/edit");
		return modelAndView;
	}
	
	// 群发信息
		@RequestMapping(value = "/sendToAll")
		@ResponseBody
		public String sendToAll() {
			
			
			systemWebSocketHandler.sendMessageToUsers(new TextMessage("123"));
			
			return "1";
		}

}
